/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('status', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ListEventInProgressRequest {
  regionIds?: [ string ](name='RegionIds'),
}

model ListEventInProgressShrinkRequest {
  regionIdsShrink?: string(name='RegionIds'),
}

model ListEventInProgressResponseBody = {
  data?: [ 
    {
      eventUpdates?: [ 
        {
          content?: string(name='Content'),
          publishTime?: long(name='PublishTime', example='1680660940017'),
        }
      ](name='EventUpdates'),
      id?: long(name='Id', example='101'),
      impacts?: [ 
        {
          product?: {
            productId?: string(name='ProductId', example='ecs'),
            productName?: string(name='ProductName'),
          }(name='Product'),
          recoveryTime?: long(name='RecoveryTime', example='1680660940017'),
          region?: {
            regionId?: string(name='RegionId', example='cn-shanghai'),
            regionName?: string(name='RegionName'),
          }(name='Region'),
          startTime?: long(name='StartTime', example='1680660940017'),
        }
      ](name='Impacts'),
      startTime?: long(name='StartTime', example='1680660940017'),
      title?: string(name='Title'),
    }
  ](name='Data'),
  requestId?: string(name='RequestId', example='56CC5080-39B9-50AD-AEA1-483D9B0F8F24'),
}

model ListEventInProgressResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListEventInProgressResponseBody(name='body'),
}

async function listEventInProgressWithOptions(tmpReq: ListEventInProgressRequest, runtime: Util.RuntimeOptions): ListEventInProgressResponse {
  Util.validateModel(tmpReq);
  var request = new ListEventInProgressShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.regionIds)) {
    request.regionIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.regionIds, 'RegionIds', 'json');
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.regionIdsShrink)) {
    body['RegionIds'] = request.regionIdsShrink;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListEventInProgress',
    version = '2020-01-17',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listEventInProgress(request: ListEventInProgressRequest): ListEventInProgressResponse {
  var runtime = new Util.RuntimeOptions{};
  return listEventInProgressWithOptions(request, runtime);
}

